<template>
	<view class="mine-page page">
		<CustomNav title="详情" :isBack="true"></CustomNav>
		<view style="padding: 30rpx;margin-top: 26%;">
			<view class="title">{{detail.title}}</view>
			<view class="time">{{detail.createTime}}</view>
			<view class="content">
				<mp-html :content="detail.content"></mp-html>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPopularById,
		getLawDetailById
	} from '@/api/animal.js';
	import {
		getArticleListApi,
		getArticleDetailApi
	} from '@/api/contact.js'
	export default {
		data() {
			return {
				detail: {},
				id: null
			}
		},
		methods: {
			getDetail() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getPopularById({
					id: this.id
				}).then(res => {
					res.content=res.content.replaceAll('src="sbbz/','src="https://report.sbmny.cn/sbbz/')
					uni.hideLoading()
					this.detail = res;
				})
			},
			getArticleDetail() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getArticleDetailApi({
					id: this.id
				}).then(res => {
					res.content=res.content.replaceAll('src="sbbz/','src="https://report.sbmny.cn/sbbz/')
					uni.hideLoading()
					this.detail = res;
				})
			},
			getLawDetail() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getLawDetailById({
					id: this.id
				}).then(res => {
					res.content=res.content.replaceAll('src="sbbz/','src="https://report.sbmny.cn/sbbz/')
					uni.hideLoading()
					this.detail = res;
				})
			},
		},
		onLoad(e) {
			this.id = e.id
			if (e.type) {
				this.getArticleDetail()
			}
			if (e.state) {
				this.getLawDetail()
			} else {
				this.getDetail()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mine-page {
		background: #fff;

		.title {
			font-weight: bold;
			font-size: 34rpx;
		}

		.time {
			font-size: 28rpx;
			color: #999;
			margin: 20rpx 0;
		}
	}
</style>